﻿@model Bidder

@{
    Layout = "~/Views/Shared/_EmptyLayout.cshtml";
    ViewBag.Title = "รายละเอียด ผู้ขาย [BD]";
    ViewBag.Descr = "รายละเอียด ผู้ขาย";
}

    @if (!(bool)ViewBag.IsFromOther)
    {
<div class="block-button-menu-above">

        @Html.ActionLink("กลับไปหน้าแสดงข้อมูลทั้งหมด", "Index", new { BidId = Model.BidId, PrId = Model.PrId }, new { @class = "btn btn-gray button-standard-width btn-small", role="button" })
    
    @if (ViewBag.bEditable)
    {
        @Html.ButtonEdit(new { id = Model.BidderId })
        @Html.ActionLink("เพิ่ม", "Create", new { BidId = Model.BidId }, new { @class = "btn btn-success button-standard-width btn-small", role="button" })
        @Html.ButtonDelete(new { id = Model.BidderId })
    }
    
</div>
    }
@Html.Partial("_DetailsForm")

<div class="widget-box transparent">
	<div class="widget-header header-color-blue2">
        <div class="widget-toolbar">
            <a href="#" data-action="collapse" style="color:#4383b4;font-size:large;" ><i class="icon-chevron-up"></i>  เสนอราคา</a>
		</div>
    </div>
    <div class="widget-body" style="padding:10px;">
        <div class="widget-main">
            <iframe id="iframe1" src="@Url.Action("Index", "BidderQuotation")?BidderId=@Model.BidderId" frameborder="0" style="width:100%;" ></iframe>
        </div>
    </div>
</div>
@if ((bool)ViewBag.bIsBid)
{
<div class="widget-box transparent collapsed">
	<div class="widget-header header-color-blue2">
        <div class="widget-toolbar">
            <a href="#" data-action="collapse" style="color:#4383b4;font-size:large;" ><i class="icon-chevron-up"></i>  หลักประกันต่างๆ</a>
		</div>
    </div>
    <div class="widget-body" style="padding:10px;">
        <div class="widget-main">
            <iframe id="iframe2" src="@Url.Action("Index", "BidderCollateral")?BidderId=@Model.BidderId" frameborder="0" style="width:100%;" ></iframe>
        </div>
    </div>
</div>
}

<div id="modal" class="modal hide fade autosize" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="height:600px; width:800px"></div>

@section scripts
{
    <script>

        $(function () {
            var lastHeight1 = 0, curHeight1 = 0, $frame1 = $('#iframe1');
            setInterval(function () {
                curHeight1 = $frame1.contents().find('body').height() + 40;
                if (curHeight1 != lastHeight1) {
                    $frame1.css('height', (lastHeight1 = curHeight1) + 'px');
                }
            }, 500);

            var lastHeight2 = 0, curHeight2 = 0, $frame2 = $('#iframe2');
            setInterval(function () {
                curHeight2 = $frame2.contents().find('body').height() + 40;
                if (curHeight2 != lastHeight2) {
                    $frame2.css('height', (lastHeight2 = curHeight2) + 'px');
                }
            }, 500);

            var $modal = $('#modal');
            $('#linkContact').on('click', function (e) {
                e.preventDefault();
                var url = $(this).attr('href');
                $modal.html('<iframe width="100%" height="100%" frameborder="0" scrolling="yes" allowtransparency="true" src="' + url + '"></iframe>');
                $modal.modal({
                    show: true
                });
            });

            $modal.on('hide', function () {
                $modal.empty(); // Clean up
                location.reload();
                //$("#table").trigger("reloadGrid");
            });

            $('.modal-body', this).css({ width: 'auto', height: 'auto', 'max-height': '100%' });

        });

    </script>
}